#include<bits/stdc++.h>
using namespace std;

const int N=1e5+10;
int d[N],v[N],a[N],p[N],b[N];
map<int,int>mp;

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    scanf("%d",&t);
    while(t--){
        for(int i=0;i<=1e5;i++){
            mp[i]=0;
        }
        int n,m,l,mx;
        scanf("%d%d%d%d",&n,&m,&l,&mx);
        int cnt=0;
        int pls=0;
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
            b[i]=d[i];
        }
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
        }
        sort(p+1,p+1+m);
        while(n>0){
            for(int i=1;i<=n;i++){
                if(a[i]<0){
                    pls++;
                }
                int srt=d[i];
                d[i]+=v[i];
                int fin=d[i];
                if(v[i]>mx){
                    for(int j=1;j<=m;j++){
                        if(p[j]>fin){
                            break;
                        }
                        if(p[j]>srt&&p[j]<=fin){
                            if(mp[i]==0){
                                mp[i]=1;
                                cnt++;
                                break;
                            }
                        }
                    }
                }
                if(d[i]>=l||v[i]<=0){
                    n--;
                    continue;
                }
                v[i]+=a[i];
            }
        }
        printf("%d %d\n",cnt,pls+1);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
